package com.guli.product.entity;

import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.guli.common.validation.AddValidation;
import com.guli.common.validation.ListValue;
import com.guli.common.validation.UpdateValidation;
import lombok.Data;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;

/**
 * 商品三级分类
 * @author zzb
 * @email 1626131069@qq.com
 * @date 2023-10-21 10:18:56
 */
@Data
@TableName("pms_category")
public class CategoryEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 分类id
     */
    @TableId
    @NotNull(message = "修改时分类ID不能为空", groups = UpdateValidation.class)
    @Null(message = "新增时分类ID必须为空", groups = AddValidation.class)
    private Long catId;
    /**
     * 分类名称
     */
    @NotNull(message = "分类名称不能为空", groups = {AddValidation.class, UpdateValidation.class})
    private String name;
    /**
     * 父分类id
     */
    @NotNull(message = "父分类ID不能为空",groups = AddValidation.class)
    @Null(message = "父分类ID必须为空", groups = {UpdateValidation.class})
    private Long parentCid;
    /**
     * 层级
     */
    @NotNull(message = "层数不能为空",groups = AddValidation.class)
    @Null(message = "层数必须为空", groups = {UpdateValidation.class})
    private Integer catLevel;
    /**
     * 是否显示[0-不显示，1显示]
     */
    @ListValue(value = {0, 1},groups = AddValidation.class)
    @TableLogic
    private Integer showStatus;

    /**
     * 排序
     */
    @Min(value = 0, message = "排序必须大于或等于0")
    private Integer sort;
    /**
     * 图标地址
     */
    private String icon;
    /**
     * 计量单位
     */
    private String productUnit;
    /**
     * 商品数量
     */
    @Min(value = 0, message = "商品数量不能小于0")
    private Integer productCount;


    @TableField(exist = false)
    @JsonInclude(value = JsonInclude.Include.NON_EMPTY)
    private List<CategoryEntity> children;

}
